<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>mvvm框架伪代码</title>
</head>
<body>
  <div id="app">
    <p>{{title}}</p>
    <input type="text" v-model="name">
    <p>{{name}}</p>
    <hr>
    <p>{{count}}<button v-on:click="add" style="transform: translateX(20px)">+数量</button></p>
  </div>
  <script type="text/javascript">
    import MVVM from './my-mvvm/main.js'
    window.$vm = new MVVM({
      el: '#app',
      data: {
        title: 'hello mvvm',
        name: 'jtr',
        count: 0
      },
      methods: {
        add() {
          this.count++
        }
      },
      mounted() {
        this.timer = setInterval(() => {
          this.title += '*'
        }, 500)
      },
      updated() {
        this.title.length > 20 && clearInterval(this.timer)
      }
    })
  </script>
</body>
</html>
